package com.hjxr.sysadmin.zsj.controller;

import java.util.List;

import com.hjxr.sysadmin.zsj.domain.ZIndustry;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hjxr.framework.aspectj.lang.annotation.Log;
import com.hjxr.framework.aspectj.lang.enums.BusinessType;
import com.hjxr.sysadmin.zsj.domain.Park;
import com.hjxr.sysadmin.zsj.service.IParkService;
import com.hjxr.sysadmin.web.controller.BaseController;
import com.hjxr.framework.web.domain.AjaxResult;
import com.hjxr.sysadmin.uitl.poi.ExcelUtil;
import com.hjxr.sysadmin.web.page.TableDataInfo;

/**
 * 园区信息Controller
 *
 * @author zc
 * @date 2021-03-22
 */
@Api("园区信息管理")
@RestController
@RequestMapping("/park")
public class ParkController extends BaseController
{
    @Autowired
    private IParkService parkService;

    /**
     * 查询园区信息列表
     */
    @ApiOperation("查询园区信息列表")
    //@PreAuthorize("@ss.hasPermi('system:park:list')")
    @GetMapping("/list")
    public TableDataInfo list(Park park)
    {
        startPage();
        List<Park> list = parkService.selectParkList(park);
        return getDataTable(list);
    }

    /**
     * 导出园区信息列表
     */
    @ApiOperation("导出园区信息列表")
    //@PreAuthorize("@ss.hasPermi('system:park:export')")
    @Log(title = "导出园区信息列表", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Park park)
    {
        List<Park> list = parkService.selectParkList(park);
        ExcelUtil<Park> util = new ExcelUtil<Park>(Park.class);
        return util.exportExcel(list, "park");
    }

    /**
     * 获取园区信息详细信息
     */
    @ApiOperation("获取园区信息详细信息")
    //@PreAuthorize("@ss.hasPermi('system:park:query')")
    @GetMapping(value = "/{parkId}")
    public AjaxResult getInfo(@PathVariable("parkId") Long parkId)
    {
        return AjaxResult.success(parkService.selectParkById(parkId));
    }

    /**
     * 新增园区信息
     */
    @ApiOperation("新增园区信息")
    //@PreAuthorize("@ss.hasPermi('system:park:add')")
    @Log(title = "新增园区信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Park park)
    {
        return toAjax(parkService.insertPark(park));
    }

    /**
     * 修改园区信息
     */
    @ApiOperation("修改园区信息")
    //@PreAuthorize("@ss.hasPermi('system:park:edit')")
    @Log(title = "修改园区信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Park park)
    {
        return toAjax(parkService.updatePark(park));
    }

    /**
     * 删除园区信息
     */
    @ApiOperation("删除园区信息")
    //@PreAuthorize("@ss.hasPermi('system:park:remove')")
    @Log(title = "删除园区信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{parkIds}")
    public AjaxResult remove(@PathVariable Long[] parkIds)
    {
        return toAjax(parkService.deleteParkByIds(parkIds));
    }

    /**
     * 获取园区主导产业信息详
     */
    @ApiOperation("获取园区主导产业信息")
    @GetMapping(value = "/industry/{parkId}")
    public AjaxResult selectIndustryById(@PathVariable("parkId") Long parkId)
    {
        return AjaxResult.success(parkService.selectIndustryById(parkId));
    }

    /**
     * 新增园区主导产业信息
     */
    @ApiOperation("新增园区主导产业信息")
    @Log(title = "新增园区主导产业信息", businessType = BusinessType.UPDATE)
    @PostMapping(value = "/addindustry")
    public AjaxResult insertIndustry(@RequestBody ZIndustry zIndustry)
    {
        return toAjax(parkService.insertIndustry(zIndustry));
    }

    /**
     * 修改园区主导产业信息
     */
    @ApiOperation("修改园区主导产业信息")
    @Log(title = "修改园区主导产业信息", businessType = BusinessType.UPDATE)
    @PostMapping(value = "/editindustry")
    public AjaxResult updateIndustry(@RequestBody ZIndustry zIndustry)
    {
        return toAjax(parkService.updateIndustry(zIndustry));
    }

    /**
     * 查询园区信息列表
     */
    @ApiOperation("查询园区范围信息列表")
    @GetMapping("/listBoundary")
    public TableDataInfo listBoundary(Park park)
    {
        startPage();
        List<Park> list = parkService.selectParkListBoundary(park);
        return getDataTable(list);
    }
}
